﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using SharppiFlowEditor.models;

namespace SharppiFlowEditor.views
{
    public class DocumentPropertiesView : ScrollableControl
    {
        private Label widthLabel, heightLabel;
        private TextBox widthTextBox, heightTextBox;
        private Button saveButton;

        public Button SaveButton { get { return saveButton; } }

        private Font usedFont;

        public String DocWidth { get { return widthTextBox.Text; } }

        public String DocHeight { get { return heightTextBox.Text; } }

        private Document _selectedDocument;
        public Document SelectedDocument
        {
            set { _selectedDocument = value; }
            get { return _selectedDocument; }
        }

        public DocumentPropertiesView()
        {
            usedFont = new Font(FontFamily.GenericSansSerif, 10.0F);

            this.Dock = DockStyle.Top;

            widthLabel = new Label();
            widthLabel.Text = "Width";
            widthLabel.Font = usedFont;
            widthLabel.Location = new Point(2, 10);
            widthLabel.Width = 55;
            heightLabel = new Label();
            heightLabel.Text = "Height";
            heightLabel.Font = usedFont;
            heightLabel.Location = new Point(2, 40);
            heightLabel.Width = 55;

            widthTextBox = new TextBox();
            widthTextBox.Font = usedFont;
            widthTextBox.Location = new Point(60, 10);
            widthTextBox.Width = 100;
            heightTextBox = new TextBox();
            heightTextBox.Font = usedFont;
            heightTextBox.Location = new Point(60, 40);
            heightTextBox.Width = 100;


            saveButton = new Button();
            saveButton.Text = "Save";
            saveButton.Location = new Point(110, 70);
            saveButton.Size = new Size(50, 25);

            this.Controls.Add(widthLabel);
            this.Controls.Add(heightLabel);
            this.Controls.Add(widthTextBox);
            this.Controls.Add(heightTextBox);
            this.Controls.Add(saveButton);
        }

        
        public void updatePropertiesView()
        {
            widthTextBox.Text = Convert.ToString(_selectedDocument.Documentsize.Width);
            heightTextBox.Text = Convert.ToString(_selectedDocument.Documentsize.Height);
        }
    }
}
